<div class="operations btns-wrapper">
    <div class="left-btns">
        <ng-content select=".left-extra"></ng-content>
        <ng-container *ngFor="let btnInfo of sortedBtnsGen?.left">
            <ng-container
                *ngTemplateOutlet="btnRenderTpl; context: {btnInfo:btnInfo,data:selectData, funSet:funSet}"></ng-container>
        </ng-container>
    </div>
    <div class="right-btns">
        <ng-container *ngFor="let btnInfo of sortedBtnsGen?.right">
            <ng-container
                *ngTemplateOutlet="btnRenderTpl; context: {btnInfo:btnInfo,data:selectData, funSet:funSet}"></ng-container>
        </ng-container>
        <ng-content select=".right-extra"></ng-content>
    </div>
</div>

<ng-template let-btnInfo="btnInfo" let-selectData="selectData" let-funSet="funSet" #btnRenderTpl>
    <ng-container *ngIf="!btnInfo.hidden">
        <ng-container *ngIf="btnInfo.type;else btnTpl">
            <ng-container [ngSwitch]="btnInfo.type">
                <ng-container *ngSwitchCase="'template'">
                    <ng-container
                        *ngTemplateOutlet="btnInfo.templateRef; context: {btnInfo:btnInfo,data:selectData, funSet:funSet}"></ng-container>
                </ng-container>
                <ng-container *ngSwitchDefault></ng-container>
            </ng-container>
        </ng-container>
        <ng-template #btnTpl>
            <ng-container *ngIf="btnInfo.confirm">
                <button *ngIf="!(btnInfo.bindChecked && dataLen === 0)"
                        [ngClass]="processClass(btnInfo.class)"
                        nz-popconfirm
                        [nzTitle]="btnInfo.confirm.title ||'确认删除选中数据吗?'"
                        [nzPlacement]="btnInfo.confirm.placement || 'top'"
                        (nzOnConfirm)="handleBtnsClick(btnInfo)"
                        [nzType]="btnInfo.zorroType"
                        [nzCancelText]="btnInfo.confirm.cancelText || '取消'"
                        [nzOkText]="btnInfo.confirm.okText || '确认'"
                        [disabled]="(btnInfo.bindChecked && !(indeterminate || allChecked)) || (btnInfo?.disableOnNoRst && dataLen === 0)"
                        [nzLoading]="btnInfo.loading"
                        nz-button>
                    {{btnInfo.name}}
                </button>
            </ng-container>
            <ng-container *ngIf="!btnInfo.confirm">
                <button *ngIf="!(btnInfo.bindChecked && dataLen === 0)"
                        [ngClass]="processClass(btnInfo.class)"
                        (click)="handleBtnsClick(btnInfo)"
                        [nzType]="btnInfo.zorroType"
                        [nzLoading]="btnInfo.loading"
                        [disabled]="(btnInfo.bindChecked && !(indeterminate || allChecked)) || (btnInfo?.disableOnNoRst && dataLen === 0)"
                        nz-button>
                    {{btnInfo.name}}
                </button>
            </ng-container>
        </ng-template>
    </ng-container>
</ng-template>
